<template>
	<view style="background-color: white;height: 100vh;">
		<view class="status_bar"> </view>
		<view class="top" >
					 <u-icon size="50rpx" name="arrow-left" @click="toBack"></u-icon>
					 <text style="text-align: center;font-weight: bold;padding-left: 250rpx;">问题反馈</text>
		</view>
		<view class="" style="margin: 20rpx 40rpx;color: #7e7d7e;">
			请在此填写您在使用过程中遇到的问题，我们将在3-5个工作日内处理，并向您反馈
		</view>
		
			<textarea v-model="form.feedback" maxlength="-1"  style="margin: 20rpx 40rpx;background-color: #f2f2f2;height: 400rpx;width: 660rpx;">
			</textarea>
		<!-- 上传图片 -->
		<view class="" style="margin: 20rpx 40rpx;">
		<block >
			<u-upload ref="uUpload" :size-type="['original', 'compressed']" name="files" :max-count="9" 
				:action="uploadImgUrl" @on-uploaded="submitimg" :auto-upload="false" height="200rpx" width="200rpx"></u-upload>
	
				
		
		</block>
		</view> 
		
		<view class="out-btn">
			<button  @click="submit" style="width: 320rpx;background-color: #ffe796;border-radius: 40rpx;">提交</button>
		</view>

	</view>
</template>


<script>
	export default {
		data() {
			return {
				state: true,
				uploadImgUrl: this.$c.domain + 'oss/upmutiload',
				form: {
				images:[]
				},
				
				location: '',
				header: {
					token: uni.getStorageSync('token')
				},
				
			};
		},
		methods:{
			submitimg(e) {
				
			    
				let mediaList = [];
				
				e.forEach(function(item, index) {
					
					mediaList.push(String(item.response.url));
					
				});
			    
				this.form.images = mediaList;
				this.$H.post('http://www.zzzsep.com:8080/api/feedBack/add?images='+this.form.images+'&content='+this.form.feedback).then(res => {
					
					if(res.code == 200){
					uni.showToast({
						icon: "success",
						title: '反馈成功',
					
					})
					setTimeout(function () {
					                        uni.navigateBack({
					                        	
					                        })
					                    }, 2000);
					
					}else{
					uni.showToast({
						icon: "none",
						title: '反馈失败'
					})
					}
				
					
				});
				uni.hideLoading();
			   // 传递帖子表单到后端的接口

				
			},
			toBack(){
				uni.reLaunch({
					url:'/pages/mine/index'
				})
			},
			submit() {
			
				if (!this.form.feedback) {
					this.$u.toast('反馈内容不能为空哦');
					return;
				}
			
				
			
				uni.showLoading({
					mask: true,
					title: '发布中'
				});
				this.$refs.uUpload.upload();
				

			},
			}
	};

</script>

<style lang="scss">
	.status_bar {
	        height: var(--status-bar-height);
	        width: 100%;
	    }
	.top{
				display: flex;
				width: 100%;
				box-sizing: border-box;
			    align-items: center;
				height: 150rpx;
				padding: 0 30rpx;
				background-color: #f2f2f2;
				
				
			}
	.out-btn {
				margin: 190rpx 30rpx;
				box-shadow: 10rpx,10rpx,5rpx,5rpx;
			
			}

</style>
